clear; clc; close all;

I512 = imread('Lena.tif');
if size(I512,3) == 3
    I512 = rgb2gray(I512);
end

s = 256;

% 缩放到256x256
I = imresize(I512, [s s]);

imwrite(I_encrypted, 'Lena_encrypted.png');

% 显示确认尺寸
disp(size(I));  % 应该显示 [256 256]

% 接下来用I绘制直方图即可
I_vec = double(I(:));
histogram(I_vec, 0:255, 'FaceColor', 'b', 'EdgeColor', 'b');
xlim([0 255]);
ylim([0 800]);
xlabel('Pixel values');
ylabel('Distribution');
